package net.gqu.main;

import java.util.Map;


public class ApplicationRestService {

	private GlobalApplicationService applicationService;
	
	public ApplicationRestService(GlobalApplicationService applicationService) {
		super();
		this.applicationService = applicationService;
	}

	@RestService(method="POST", uri="/application/create")
	public Map<String, Object> createApp(@RestParam(value="name")String name,
			@RestParam(value="alias")String alias,
			@RestParam(value="description")String description,
			@RestParam(value="repository")String repository,
			@RestParam(value="stage")String stage,
			@RestParam(value="type")String type,
			@RestParam(value="details")String details,
			@RestParam(value="categories")String categories,
			@RestParam(value="start")String start,
			@RestParam(value="user")String user
	) {
		Application app = applicationService.createApplication(name, alias, description, repository, start,
				Integer.parseInt(stage), Integer.parseInt(type), details, categories.split(" "), user);
		return app.getMaps();
	}
	
	@RestService(method="GET", uri="/application/get")
	public Map<String, Object> getApp(@RestParam(value="name")String name) {
		return applicationService.getApplication(name);
	}

}

